package com.ym.b2b.complaint.dao.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import com.ym.b2b.commons.dao.BaseDao;
import com.ym.b2b.complaint.dao.EmBComplaintDAO;
import com.ym.b2b.complaint.sqlbean.EmBComplaint;
import com.zc.commons.base.Page;

@Repository
public class EmBComplaintDAOImpl<T> extends BaseDao<T> implements EmBComplaintDAO {

    @Override
    public Long searchPageEmBComplaintNum(EmBComplaint embcomplaint) throws DataAccessException {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("map", embcomplaint);
        return (Long) listNum("EM_B_COMPLAINT.searchPageEmBComplaintNum", map);
    }

    @Override
    public Page searchPageEmBComplaint(EmBComplaint embcomplaint, Page<EmBComplaint> page) throws DataAccessException {
        page.setTotalRow(searchPageEmBComplaintNum(embcomplaint));
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("map", embcomplaint);
        map.put("startrow", page.getStartRow());
        map.put("pagesize", page.getPageSize());
        map.put("pageable", page.getPageable());
        page.setRows(list("EM_B_COMPLAINT.searchPageEmBComplaint", map));
        return page;
    }

    @Override
    public void insertEmBComplaint(EmBComplaint record) throws DataAccessException {
        insert("EM_B_COMPLAINT.insertEmBComplaint", record);
    }

    @Override
    public int updateEmBComplaint(EmBComplaint record) throws DataAccessException {
        int rows = update("EM_B_COMPLAINT.updateEmBComplaint", record);
        return rows;
    }

    @Override
    public int updateEmBComplaintBat(EmBComplaint record) {
        int rows = update("EM_B_COMPLAINT.updateEmBComplaintBat", record);
        return rows;
    }

    @Override
    public EmBComplaint searchEmBComplaint(Long complaintId) throws DataAccessException {
        EmBComplaint key = new EmBComplaint();
        key.setComplaintId(complaintId);
        EmBComplaint record = (EmBComplaint) find("EM_B_COMPLAINT.searchEmBComplaint", key);
        return record;
    }

    @Override
    public int deleteEmBComplaint(Long complaintId) throws DataAccessException {
        EmBComplaint key = new EmBComplaint();
        key.setComplaintId(complaintId);
        int rows = delete("EM_B_COMPLAINT.deleteEmBComplaint", key);
        return rows;
    }

    @Override
    public int deleteMultipleEmBComplaint(String complaintIdList) {
        int rows = delete("EM_B_COMPLAINT.deleteMultipleEmBComplaint", complaintIdList);
        return rows;
    }

}
